<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="renderer" content="webkit">
  <title>EZOPEN播放协议</title>
  <style>
    html,
    body {
      padding: 0;
      margin: 0;
      width: 100%;
      height: 100%;
	  overflow:hidden;
    }

    .hint {
      font-size: 14px;
      line-height: 3em;
      color: gray;
    }

    #url,
    #url2,
    #accessToken {
      width: 100%;
    }

    .btn-container {
      margin: 10px;
    }

    .normal {
      color: green;
      margin: 5px;
    }

    .error {
      color: red;
      margin: 5px;
    }
  </style>
</head>
<script>
</script>

<body>
  <script src="../ezuikit.js"></script>
  <!-- <script src="../js/jsPlugin-1.2.0.js"></script> -->
  <script src="../js/jquery.min.js"></script>
  <!-- <div class="hint">demo页面仅为代码示例无法直接运行，需要部署到服务器上才可以播放。另外监控模式与多窗口模式对浏览器版本有要求：Chrome: 55+ Firefox: V55+。</div>
  <h2>预览，回放功能示例：</h2>
  <textarea id="url" placeholder="这里输入ezopen地址"></textarea>
  <textarea id="accessToken" placeholder="这里输入accessToken"></textarea>
  <div class="btn-container">
    <button id="init">初始化播放</button>
    <button id="play">播放</button>
    <button id="stop">结束</button>
    <button id="getOSDTime">获取OSD时间</button>
    <button id="openSound">打开声音（默认已经开启）</button>
    <button id="closeSound">关闭声音</button>
    <button id="capturePicture">视频截图</button>
    <button id="startSave">开始录像</button>
    <button id="stopSave">停止录像</button>
    <button id="enableZoom">开启电子放大</button>
    <button id="closeZoom">关闭电子放大</button>
    <span>录制功能不支持加密视频，且录制的文件需要<a href="https://service.ys7.com/downloadInfoSite/admin" target="_blank">下载海康播放器播放</a></span>

  </div> -->
  <div id="playWind" style="width: 285px; height: 251px;">
  </div>
  <script>
    function playvideo() {

      var url = window.location.search //获取url中"?"符后的字串 并进行分割
      let result = {},
        reg1 = /([^?=&#]+)=([^?=&#]+)/g,
        reg2 = /#([^?=&#]+)/g

      url.replace(reg1, (n, x, y) => (result[x] = y))
      url.replace(reg2, (n, x) => (result['HASH'] = x))

      console.log(result)
      console.log($('html').width)
      console.log($('html').height)

      var decoder = new EZUIKit.EZUIPlayer({
        id: 'playWind',
        autoplay: true,
        url: 'ezopen://open.ys7.com/F44041969/1.hd.live',
        accessToken: result.token,
        decoderPath: '',
        width: 285,
        height: 251,
        handleError: handleError,
        handleSuccess: handleSuccess,
      });

      function handleError(e) {
        console.log('捕获到错误', e)
      }
      function handleSuccess() {
        console.log("播放成功回调函数，此处可执行播放成功后续动作");
      }

      setTimeout(() => {
        decoder.play();
        // decoder.enableZoom();
      }, 1000)
    }
    playvideo();
  </script>
</body>

</html>